package com.yyc.system.controller;
import com.yyc.core.Result;
import com.yyc.core.ResultGenerator;
import com.yyc.system.model.TUser;
import com.yyc.system.service.ITUserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
* Created by yyc on 2018/12/26.
*/
@RestController
@RequestMapping("/log")
public class LoginController {
    @Autowired
    private ITUserService tUserService;

    /**
	 * 统一用户登陆
	 * 
	 * @param request request请求
	 * @param user    user对象
	 * @return user对象或userDetail（带有公司信息的对象）对象
	 */
	@RequestMapping("/login")
	public Result login(@RequestBody TUser user) {
		TUser tUser = tUserService.login(user);
		if(tUser!=null){
			return ResultGenerator.genSuccessResult(tUser);
		}else{
			return ResultGenerator.genFailResult("登陆失败");
		}
	}
}
